<?php if(!defined('APP_ROOT')){exit('error!');}?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $site_title;?></title>
<link type="text/css" href="<?php echo PUBLIC_URL;?>css/font-awesome.min.css" rel="stylesheet">
<link type="text/css" href="<?php echo TEMPLATE_URL;?>style.css" rel="stylesheet">
<script type="text/javascript" src="<?php echo PUBLIC_URL;?>js/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo TEMPLATE_URL;?>js/manage.js"></script>
</head>
<body>
<?php include View::getView('header');?>
<?php include View::getView('side');?>
<div id="mainbox">
    <div class="wrapper">
        <div class="main">
            <div class="itembox w100">
                <div class="wrap">
                    <h2><?php echo $page_title;?> <span><a href="<?php echo APP_URL;?>shop/index">返回店铺列表</a></span></h2>
                    <div class="itemmain">
                        <div id="adm_shop_edit">
                            <div class="head">
                                
                            </div>
                            <form name="editForm" onsubmit="return postEditForm()">
                                <table width="100%" cellpadding="0" cellspacing="0" class="adm_table" >
                                    <tr>
                                        <td width="100">店铺名称</td>
                                        <td>
                                            <input type="text" name="shopname" class="bar bar1">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>包含渠道</td>
                                        <td>
                                            <?php foreach($ditches as $ditch):?>
                                            <input type="checkbox" name="shopditches[]" value="<?php echo $ditch['did'];?>" id="ditch_<?php echo $ditch['did'];?>"><label for="ditch_<?php echo $ditch['did'];?>"><?php echo $ditch['ditchname'];?></label> &nbsp;
                                            <?php endforeach;?>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>店铺说明</td>
                                        <td><textarea name="description" class="text text1"></textarea></td>
                                    </tr>
                                    <tr>
                                        <td></td>
                                        <td>
                                            <input type="hidden" name="action" value="editShop">
                                            <input type="hidden" name="token" value="<?php echo loginAuth::genToken();?>">
                                            <input type="submit" value="提交保存" class="btn">
                                        </td>
                                    </tr>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php include View::getView('footer');?>
    </div>
</div>
<script type="text/javascript">
function postEditForm(){
    var theData = $("form[name=editForm]").serialize();
    $.ajax({
        'type':'post',
        'dataType':'json',
        'url':'<?php echo APP_URL;?>shop/handle',
        'data':theData,
        'success':function(data){
            alert(data.msg);
            if(data.result==200){
                location.href='<?php echo APP_URL;?>shop/index';
            }
        }
    });
    return false;
}
</script>
</body>
</html>